<?php

	function verifAdherent()
	{
		$sql_host = "localhost";
		$sql_user = "dansuser";
		$sql_pass = "danspass";
		$sql_db_name= "Dansin";
	
		/*******************************************************************/
		/*                   Connexion au serveur MySQL                    */
		/*******************************************************************/
	
		try{
			$connexion = new PDO('mysql:host='.$sql_host.';dbname='.$sql_db_name,$sql_user,$sql_pass);		
		}
		catch(exception $e){
        	echo 'Erreur : '.$e->getMessage().'<br />';
        	echo 'N° : '.$e->getCode();		
		}
	
		/*******************************************************************/
		/*                Insertion de tables dans la bdd                  */
		/*******************************************************************/
		$email = htmlspecialchars($_POST['email']);
		$password = htmlspecialchars(md5($_POST['password']));
		$nbreEmail = $connexion->query("SELECT COUNT(ad_mail) FROM Adherent WHERE ad_mail='".$email."';");
		
		if($nbreEmail->fetchColumn()==0){
			$connexion = null;
			return FALSE;
		}
		else{
			$req_password = $connexion->query("SELECT * FROM Adherent WHERE ad_mail='".$email."';");
			$donnee = $req_password->fetch();
			if($password == $donnee['ad_mdp']){
				$connexion = null;
				return $donnee;
			}
			else{
				$connexion = null;
				return FALSE;
			}
		}
	
		/*******************************************************************/
		/*                   Deconnexion du serveur MySQL                  */
		/*******************************************************************/
	
		$connexion = null;
	}

?>